Modern computer systems are capable of supporting multithreaded and multiprocess applications. These computer systems include single processor systems that perform simultaneous multithreading, multicore processor systems, and multiple processor systems. Applications, such as network packet processing, which are highly parallel and typically multithreaded and/or multiprocessed are able to take advantage of these capabilities in these computers systems
In a parallel programming paradigm, accesses to global resources are often protected to ensure mutual exclusiveness and synchronizations between threads. The instructions in code which require mutual exclusiveness and synchronization between threads may be referred to as critical sections. Critical sections may be protected by using a token based protection scheme where each thread awaits a signal from a previous thread before entering a critical section. Upon receiving the signal, the thread may execute the code in the critical section exclusively. After the code has been executed, the thread may send a signal to a next thread which allows the next thread to enter the critical section. In such a token based critical section implementation, each thread is required to pass a token, such as a signal, to a next thread exactly once in any path of the program.
In such a parallel programming paradigm, critical sections with different orders on different execution paths and critical sections having more instructions than required may adversely impact the performance of a program.